package 素数筛选.计数质数;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: jszs
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-06 19:39
 **/
public class jszs {
    public static void main(String[] args) {
        System.out.println(countPrimes(10));
    }
    public static int countPrimes(int n) {
        if( n<= 1){
            return 0;
        }
        int[] arr = new int[n];
        arr[0] = 1;
        arr[1] = 1;

        for (int i = 2; i < arr.length; i++) {
            int min =  i;
            System.out.println("当前最小 "+min);
            for (int j = i; j < arr.length; j+=i) {
                if (j % min == 0 && j!=min){
                    System.out.println(j+" 被标记");
                    arr[j] = 1;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
        return (int)Arrays.stream(arr).filter(value -> value == 0).count();
    }

}
